package com.mediacloud.app.newsmodule.fragment.webview;


import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.webkit.URLUtil;
import android.widget.ProgressBar;

import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import com.mediacloud.app.assembly.util.Utility;
import com.mediacloud.app.assembly.views.InnerDialogView;
import com.mediacloud.app.assembly.views.InnerDialogView.InnerDialogListener;
import com.mediacloud.app.fbnavsk.SecondFloorHandlerKt;
import com.mediacloud.app.model.eventbus.event.LoginEvent;
import com.mediacloud.app.model.news.ArticleItem;
import com.mediacloud.app.model.news.kt.TypeX;
import com.mediacloud.app.model.utils.NeedTokenType;
import com.mediacloud.app.model.utils.WebUrlContractParam;
import com.mediacloud.app.model.view.WebBrowserX;
import com.mediacloud.app.nav2.fragment.HqyNavFragment;
import com.mediacloud.app.newsmodule.R;
import com.mediacloud.app.newsmodule.activity.WebViewPageActivity;
import com.mediacloud.app.newsmodule.javascript.H5PayJavaScriptInterface;
import com.mediacloud.app.newsmodule.utils.LoginUtils;
import com.mediacloud.app.newsmodule.utils.MJavaScriptInterfaceX;
import com.mediacloud.app.user.model.UserInfo;
import com.tencent.smtt.sdk.WebChromeClient;
import com.tencent.smtt.sdk.WebStorage;
import com.tencent.smtt.sdk.WebView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import permissions.dispatcher.PermissionUtils;


@SuppressLint("HandlerLeak")
@SuppressWarnings("ALL")
public class WebViewFragment extends HqyNavFragment {

    protected final String ViewId = UUID.randomUUID().toString();
    protected WebBrowserX mWebBrowser;
    private MJavaScriptInterfaceX mInterface;
    protected String locationUrl = null;
    protected ArticleItem articleItem;
    //protected SimpleDialog progressDialog;
    protected ProgressBar webPageLoadProgress;
    //protected ImageView mLoadingImage;
    //  protected View mLoadingLayout;
    protected boolean flag = false;
    protected boolean componentFirst = true;//来自组件的外链，第一次不管他，内跳转后在设置成不是组件的
    protected boolean delayLoginTag = false;

    protected InnerDialogView dialogView;
    protected int needToken;
    protected final int LOGIN_CODE = 999;
    protected int invokeShouldLoaderUrlTimes = 0;
    /**
     * 在pause是否是登录的
     */
    protected boolean beforePauseIsLogin = false;
    protected boolean isInvokedLogin;

    protected String afterMgSignUrlOrgin;
    public static final String GETMFSIGN = "mfsign";
    public static final String ANDROID = "android";
    public static final String H5PAY = "H5APP";
    public String newsType = "";
    //    public String newsType = "https://morefunh5.junhao.chinamcloud.com/offRoadHomePage?act_id=93b074d5-3c92-4a2f-ad1c-27099008384b";
    public WebViewPageActivity webViewPageActivity;


    View broccoli;


    private String lastRedirectUrl = "";
    private boolean isLoadPayRedirectUrl = false;
    public boolean isShowBroccoli = true;

    @Override
    public int getLayoutResID() {
        return R.layout.aappfactory_fragment_link_webview;
    }

    @Override
    public void initView() {
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        webPageLoadProgress = findViewById(R.id.webPageLoadProgress);
        mWebBrowser = findViewById(R.id.mWebBrowser);
        loadingView = Utility.findViewById(mRootView, R.id.mLoadingView);
        broccoli = Utility.findViewById(mRootView, R.id.broccoli);
        initStateView();
        loadingView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!TYPE_LOADING.equals(currentState)) {
                    showStateView(TYPE_LOADING, false);
                    mWebBrowser.loadUrl(locationUrl);
                }
            }
        });

        //		WebSettings settings=mWebBrowser.getSettings();
        //		settings.setTextSize(WebSettings.TextSize.SMALLEST);
        //		settings.setTextSize(WebSettings.TextSize.SMALLER);
        //		settings.setTextSize(WebSettings.TextSize.NORMAL);
        //		settings.setTextSize(WebSettings.TextSize.XLARGE);
        //		settings.setTextSize(WebSettings.TextSize.LARGEST);
        mInterface = new MJavaScriptInterfaceX(getActivity(), mWebBrowser);
        mWebBrowser.addJavascriptInterface(mInterface, GETMFSIGN);
        mWebBrowser.addJavascriptInterface(mInterface, ANDROID);
        H5PayJavaScriptInterface h5pay = new H5PayJavaScriptInterface(getActivity());
        mWebBrowser.addJavascriptInterface(h5pay, H5PAY);
        setWebViewParam();
        // progressDialog = new SimpleDialog(getActivity());
        // progressDialog.setCancelable(true);
        setLoadImage();
        locationUrl = getFragmentArguments().getString("url");
        newsType = getFragmentArguments().getString("newsType", "");
        articleItem = getFragmentArguments().getParcelable("data");
        //  progressDialog.updateText(R.string.hard_loading);
        //  progressDialog.show();
        initWebViewClient();
        needToken = getFragmentArguments().getInt("tag", NeedTokenType.Delayed);

        if (!isShowBroccoli) {
            closeStateView();
        }
        //如果是立马要token信息的
        if (needToken == NeedTokenType.RightNow) {
            flag = true;
            getLoginInfo();
        } else if (needToken == NeedTokenType.Delayed) {
            getLoginInfo();
        } else if (TextUtils.isEmpty(locationUrl) == false) {
            if (!newsType.equals(TypeX.CUSTOM.ADVERT + ""))
                locationUrl = WebUrlContractParam.getContract(locationUrl, getActivity());
            afterMgSignUrlOrgin = locationUrl;
            mWebBrowser.loadUrl(locationUrl);
//            mWebBrowser.loadUrl("https://morefunh5.junhao.chinamcloud.com/offRoadHomePage?act_id=93b074d5-3c92-4a2f-ad1c-27099008384b");
        }

    }


    protected void setWebViewParam() {
        mWebBrowser.setInitialScale(25);
        mWebBrowser.getSettings().setSupportZoom(true);
        mWebBrowser.getSettings().setBuiltInZoomControls(true);
        mWebBrowser.getSettings().setDisplayZoomControls(false);
        mWebBrowser.getSettings().setUseWideViewPort(true);

    }

    protected void onSetTitle(String title) {
    }

    protected boolean isComplete = false;

    private boolean isNeedPay = true;

    public boolean checkWeiMeng(String url, WebView view) {

        boolean need = false;
        if (TextUtils.isEmpty(url)) {
            return need;
        }
        String redirectURLKey = "redirect_url";
        if (url.startsWith("https://wx.tenpay.com/") && url.contains("wmReqModify=1")) {
            if (view.canGoBack()) {
                view.goBack();
            }
            return true;
        }
        if (url.startsWith("https://wx.tenpay.com/") && !url.contains("wmReqModify=1")) {

            String preUrl = "";
            String[] split = url.split("\\?");
            if (split != null && split.length > 0) {
                preUrl = split[0];
            }

            need = true;
            Map<String, String> urlParam = AnalysisURLUti.getUrlParam(url, false);
            String oldReicUrl = urlParam.get(redirectURLKey);
            if (urlParam != null) {
                try {
                    String newRedicUrl = URLEncoder.encode(AnalysisURLUti.scheme + oldReicUrl, "utf-8");
                    urlParam.put(redirectURLKey, newRedicUrl);
                    urlParam.put("wmReqModify", "1");
                    String insertParam = AnalysisURLUti.insertParam(urlParam);
                    if (!TextUtils.isEmpty(insertParam)) {
                        url = preUrl + "?" + insertParam;
                    }
                    Map header = new HashMap<String, String>();
                    header.put("Referer", URLDecoder.decode(oldReicUrl, "utf-8"));
                    view.loadUrl(url, header);
                    isNeedPay = true;
                    need = true;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

        } else if (url.startsWith("weixin://")) {
            if (!isNeedPay) {
                view.goBack();
                isNeedPay = true;
                return true;
            }
            isLoadPayRedirectUrl = false;
            need = true;
            isNeedPay = false;
            Intent intent = null;
            try {

                intent = Intent.parseUri(url.toString(), Intent.URI_INTENT_SCHEME);
                intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                // forbid launching activities without BROWSABLE category
                intent.addCategory(Intent.CATEGORY_BROWSABLE);
                // forbid explicit call
                intent.setComponent(null);
                // forbid intent with selector intent
                intent.setSelector(null);
                getActivity().startActivity(intent);
                need = true;
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (url.startsWith(AnalysisURLUti.scheme)) {
            need = true;
            try {
                url = URLDecoder.decode(url, "utf-8").substring(AnalysisURLUti.scheme.length());
                lastRedirectUrl = url;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        if (need) {
            return need;
        } else {
            return false;
        }
    }

    protected void initWebViewClient() {
       // HWStepUtils.getTodayStepsWithSupportAndAuth(getActivity(),false);
        mWebBrowser.setOnKeyListener(new OnKeyListener() {

            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
                    if (mWebBrowser.canGoBack()) {
                        mWebBrowser.goBack();
                        return true;
                    }
                }
                return false;
            }
        });
        //判断当前URL为VR，且OS版本小于 8.0.0时
        if (!TextUtils.isEmpty(locationUrl) && locationUrl.contains("720yun") && Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
            //关闭硬件加速（低版本系统的硬件加速不兼容-可以阻止软件整体崩溃，但不能正常使用VR）
            mWebBrowser.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            //提升webView的缓存大小。
            mWebBrowser.setWebChromeClient(new WebChromeClient() {
                @Override
                public void onReachedMaxAppCacheSize(long spaceNeeded, long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
                    super.onReachedMaxAppCacheSize(spaceNeeded, totalUsedQuota, quotaUpdater);
                    quotaUpdater.updateQuota(spaceNeeded * 4);
                }
            });
        }

        mWebBrowser.setWebChromeClient(new WebBrowserX.WebChrome(getActivity(), mWebBrowser, this) {


            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                super.onProgressChanged(view, newProgress);
                if (newProgress == 0) {
                    isComplete = false;
                }
                if (isComplete)
                    return;
                if (newProgress < 100) {
                    //					webPageLoadProgress.setVisibility(View.VISIBLE);
                    //					webPageLoadProgress.setProgress(newProgress);
                    Message message = Message.obtain();
                    message.what = 1;
                    message.arg1 = newProgress;
                    getHandler().sendMessage(message);
                } else {
                    //					webPageLoadProgress.setVisibility(View.GONE);
                    getHandler().sendEmptyMessage(0);
                }

            }

            @Override
            public void onReceivedTitle(WebView view, String title) {

                Log.i("test", "onReceivedTitle:" + title);
//                isComplete = true;
//                handler.sendEmptyMessage(0);
                super.onReceivedTitle(view, title);
                //progressDialog.dismiss();
//                setLoadImageGone();
                if (URLUtil.isNetworkUrl(title) || TextUtils.isEmpty(title) || title.startsWith("http"))
                    return;
                onSetTitle(title);
            }


        });
        mWebBrowser.setWebViewClient(new WebBrowserX.WebClient(getActivity(), mWebBrowser) {

            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //progressDialog.dismiss();
                setLoadImageGone();
                getHandler().sendEmptyMessage(0);

            }

            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);
                isComplete = false;
//                setLoadImageVisible();
            }

            @Override
            protected void pageError() {
                super.pageError();
                setLoadImageGone();
            }
        });
    }

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (mWebBrowser != null)
            mWebBrowser.onActivityResult(requestCode, resultCode, data);
//        if (requestCode == HWHealthHelper.REQUEST_AUTH && HWStepUtils.isSupport(getActivity())) {
//            HWHealthHelper.onActivityResult(getActivity(), requestCode, resultCode, data);
//        }

    }

    @Override
    public void onPause() {
        super.onPause();
        if (mWebBrowser != null)
            mWebBrowser.onPause();
        UserInfo userInfo = UserInfo.getUserInfo(getActivity());
        beforePauseIsLogin = userInfo.isLogin();
    }

    @Override
    public void onResume() {
        super.onResume();
        if (mWebBrowser != null)
            mWebBrowser.onResume();
        //       mWebBrowser.morefunObjcGetUserInfo(); 测试用

//        onResultOrResumeHandle();


        if (!isLoadPayRedirectUrl && !TextUtils.isEmpty(lastRedirectUrl) && mWebBrowser != null) {
            mWebBrowser.loadUrl(lastRedirectUrl);
            lastRedirectUrl = "";
            isLoadPayRedirectUrl = true;
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onResultOrResumeHandle(LoginEvent loginEvent) {
        isInvokedLogin = false;
        UserInfo userInfo = UserInfo.getUserInfo(getActivity());
        //如果不需要登录 或是在pause之前是已经登录的 就不执行后面的操作了  如果 是后续登录并且 如果pause之前没有登录 resume后也没有登录 那也返回
        if (needToken == NeedTokenType.Unnecessary || beforePauseIsLogin || (needToken == NeedTokenType.Delayed && !beforePauseIsLogin && !userInfo.isLogin()))
            return;
        if (dialogView != null) {
            dialogView.dismiss();
            dialogView = null;
        }
        if (needToken == NeedTokenType.RightNow) {
            flag = true;
            getLoginInfo();
        } else if (needToken == NeedTokenType.Delayed) {
            delayLoginTag = false;//!userInfo.isLogin();
            getLoginInfo();
        }
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (mInterface != null) {
            mInterface.onDestory();
        }
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }

    @Override
    public void onDestroy() {
        if (getHandler() != null) {
            getHandler().removeMessages(0);
            getHandler().removeMessages(1);
        }
        if (mWebBrowser != null) {
            mWebBrowser.removeJavascriptInterface(GETMFSIGN);
            mWebBrowser.removeJavascriptInterface(ANDROID);
            mWebBrowser.removeJavascriptInterface(H5PAY);
            mWebBrowser.loadUrl("about:blank");
            mWebBrowser.stopLoading();
            mWebBrowser.destroy();
        }
        if (dialogView != null) {
            dialogView.dismiss();
            dialogView.dialogListener = null;
            dialogView = null;
        }
        super.onDestroy();
    }

    protected int lastProgress = 0;

    @Override
    public boolean handleMessage(Message msg) {
        super.handleMessage(msg);
//        int max = 80;
        if (msg.what == 1) {
            int progress = msg.arg1;
//            if (lastProgress >= max) {
//                if (progress > lastProgress) {
//                    return false;
//                } else if (progress < lastProgress) {
//                    lastProgress = 0;
//                }
//            }
            webPageLoadProgress.setProgress(progress);
            webPageLoadProgress.setVisibility(View.VISIBLE);
//            if (msg.arg1 >= max) {
//                getHandler().sendEmptyMessage(0);
//            }
//            lastProgress = progress;
        } else if (msg.what == 0) {
            webPageLoadProgress.setVisibility(View.GONE);
            setLoadImageGone();
        }
        return true;
    }

    protected void getLoginInfo() {
        UserInfo userInfo = UserInfo.getUserInfo(getActivity());
        if (userInfo.isLogin()) {
            if (TextUtils.isEmpty(locationUrl) == false) {

                String tempurl;
                if (!newsType.equals(TypeX.CUSTOM.ADVERT + ""))
                    tempurl = WebUrlContractParam.getContractUserInfoUrl(userInfo, locationUrl, getActivity());
                else
                    tempurl = locationUrl;
                afterMgSignUrlOrgin = tempurl;
                mWebBrowser.loadUrl(tempurl);
            }
        } else if (flag) {
            showLoginDialog();
        } else if (delayLoginTag) {
            goTologin();
        } else if (needToken == NeedTokenType.Delayed) {
            if (TextUtils.isEmpty(locationUrl) == false) {
                String tempurl;
                if (!newsType.equals(TypeX.CUSTOM.ADVERT + ""))
                    tempurl = WebUrlContractParam.getContract(locationUrl, getActivity());
                else
                    tempurl = locationUrl;
                mWebBrowser.loadUrl(tempurl);
            }
        }
    }

    protected void showLoginDialog() {
        setLoadImageGone();
        // progressDialog.dismiss();
        if (dialogView != null) {
            dialogView.dismiss();
            dialogView.dialogListener = null;
            dialogView = null;
        }
        if (getActivity() != null) {
            dialogView = new InnerDialogView(getActivity());
        } else {
            dialogView = new InnerDialogView(getContext());
        }
        dialogView.attachView(getRealyContentView());
        dialogView.setTitle(this.getContext().getResources().getString(R.string.mediacloudapp_no_login_msg));
        dialogView.setOkayLabel(R.string.go_to_login);
        dialogView.setCancelLabel(R.string.cancel);
        dialogView.setDialogContent(R.string.mediacloudapp_no_login_msg);
        dialogView.dialogListener = new InnerDialogListener() {

            @Override
            public void innerDialogOkAction() {
                dialogView.dismiss();
                dialogView = null;
                goTologin();
            }

            @Override
            public void innerDialogCancelAction() {
                FragmentActivity activity = getActivity();
                if (WebViewFragment.this instanceof NavigateLinkFragment) {
                    dialogView.dismiss();
                    dialogView = null;
                    getLoginInfo();
                } else {
                    activity.finish();
                }
            }
        };
    }

    protected synchronized void goTologin() {
        if (isInvokedLogin)
            return;
        isInvokedLogin = true;
//        Intent loginIntent = new Intent();
//        loginIntent.setClassName(getActivity(), ModuleReferenceConfig.LoginActivity);
//        loginIntent.putExtra("id", FGTag.TagID);
//        startActivityForResult(loginIntent, LOGIN_CODE);
        Intent loginIntent = new Intent();
        loginIntent.putExtra("id", FGTag.TagID);
        LoginUtils.request_source = "网页";
        LoginUtils.invokeLogin(getActivity(), loginIntent, LOGIN_CODE);
    }


    @Override
    public void onSaveInstanceState(Bundle outState) {
        outState.putInt("tag", needToken);
        outState.putString("url", locationUrl);
        super.onSaveInstanceState(outState);
    }

    public void setLoadImage() {
//        mLoadingImage = findViewById(R.id.mLoadingImage);
//        mLoadingLayout = findViewById(R.id.mLoadingLayout);
//        if (!TextUtils.isEmpty(AppFactoryGlobalConfig.getAppServerConfigInfo(getActivity()).getH5LoadImg())) {
//            FunKt.load(mLoadingImage,AppFactoryGlobalConfig.getAppServerConfigInfo(getActivity()).getH5LoadImg(),ContextCompat.getDrawable(getActivity(), R.drawable.default_load));
//          //  GlideUtils.loadUrl(AppFactoryGlobalConfig.getAppServerConfigInfo(getActivity()).getH5LoadImg(), mLoadingImage, null, ContextCompat.getDrawable(getActivity(), R.drawable.default_load),true);
//        } else if (getActivity() != null) {
//            Glide.with(getActivity()).load(R.drawable.default_load).into(mLoadingImage);
//        }
//        Map<String, ? extends Object> value = AppSharePreference.getSharedData(NativeDataSaveKey.WebLoadImageMD5Name, getActivity());
//        String loadImageName = value != null && value.containsKey(NativeDataSaveKey.WebLoadImageMD5Name) ? value.get(NativeDataSaveKey.WebLoadImageMD5Name).toString() : "";
//        if (TextUtils.isEmpty(loadImageName)) {
//            Glide.with(this).load(R.drawable.default_load).into(mLoadingImage);
//        } else {
//            String filePath = FileUtil.CACHE + "WebLoadImage/" + loadImageName;
//            if (FileUtil.isFileEnable(filePath) && (FileUtil.getFileName(filePath).endsWith(".png") || FileUtil.getFileName(filePath).endsWith(".gif"))) {
//                File file = new File(filePath);
//                Glide.with(this).load(file).into(mLoadingImage);
//            } else {
//                Glide.with(this).load(R.drawable.default_load).into(mLoadingImage);
//            }
//        }
        //mLoadingLayout.setVisibility(View.VISIBLE);
        showStateView(TYPE_LOADING, false);
    }

    public static final String ACTION="com.mediacloud.app.thiscontainerisvisible";
    public static final String TITLEACTION = "com.mediacloud.app.resetnametitle";

    public void setLoadImageGone() {
        closeStateView();
        LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(new Intent(ACTION));

//        if (mLoadingLayout.getVisibility() == View.VISIBLE) {
//            mRootView.post(new Runnable() {
//                @Override
//                public void run() {
//                    mLoadingLayout.setVisibility(View.GONE);
//                }
//            });//, 2500);
//            LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(new Intent(ACTION));
//        }
    }

    public void setLoadImageVisible() {
        mRootView.post(new Runnable() {
            @Override
            public void run() {
                setLoadImage();
            }
        });
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (mWebBrowser == null)
            return;
        try {
            if (hidden) {
                mWebBrowser.onPause();
            } else {
                mWebBrowser.onResume();
            }
        } catch (Exception e) {
        }

    }

    @Override
    public void choosed() {
        super.choosed();
        onHiddenChanged(false);
    }

    @Override
    public void unChosoed() {
        super.unChosoed();
        onHiddenChanged(true);
    }


    @Override
    public final void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (getActivity() == null)
            return;
        if (PermissionUtils.hasSelfPermissions(getActivity(), permissions)) {
            if (mWebBrowser != null) {
                mWebBrowser.alllowedCameraPermissons();
            }
        } else if (PermissionUtils.shouldShowRequestPermissionRationale(getActivity(), permissions)) {
            ActivityCompat.requestPermissions(getActivity(), permissions, permissions.length);
        } else {
            if (mWebBrowser != null) {
                mWebBrowser.rejectCameraPermissons();
                showRationaleDialog(R.string.note_give_permission);
            }
        }
    }

    final void showRationaleDialog(int messageResId) {
        new AlertDialog.Builder(getActivity())
                .setPositiveButton(R.string.button_allow, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(@NonNull DialogInterface dialog, int which) {
                        Utility.getAppDetailSettingIntent(getActivity());
                    }
                })
                .setNegativeButton(R.string.button_deny, null)
                .setCancelable(false)
                .setTitle(R.string.help)
                .setMessage(messageResId)
                .show();
    }

    @CallSuper
    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        SecondFloorHandlerKt.navPaddingTopMatch(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void userLoginEvent(LoginEvent loginEvent) {
        if (UserInfo.getUserInfo(requireActivity()).isLogin()) {
            if (afterMgSignUrlOrgin != null) {
                if (mInterface != null && afterMgSignUrlOrgin.contains("credits") || afterMgSignUrlOrgin.contains("credits")) {
                    mInterface.setUserInfoByJS();
                }
            }
        }
    }

    @Override
    public void closeStateView() {
        super.closeStateView();
        if (broccoli != null)
            broccoli.setVisibility(View.GONE);
    }
}
